

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>mindspore.dataset.config &mdash; MindSpore master documentation</title>
  

  
  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
        <script src="../_static/jquery.js"></script>
        <script src="../_static/underscore.js"></script>
        <script src="../_static/doctools.js"></script>
        <script src="../_static/language_data.js"></script>
        <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <script type="text/javascript" src="../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="mindspore.dataset.text" href="mindspore.dataset.text.html" />
    <link rel="prev" title="mindspore.dataset.audio.utils.ScaleType" href="dataset_audio/mindspore.dataset.audio.utils.ScaleType.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../index.html" class="icon icon-home"> MindSpore
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">MindSpore Python API</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="mindspore.html">mindspore</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.common.initializer.html">mindspore.common.initializer</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.communication.html">mindspore.communication</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.compression.html">mindspore.compression</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.context.html">mindspore.context</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.dataset.html">mindspore.dataset</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.dataset.audio.html">mindspore.dataset.audio</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">mindspore.dataset.config</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.dataset.text.html">mindspore.dataset.text</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.dataset.transforms.html">mindspore.dataset.transforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.dataset.vision.html">mindspore.dataset.vision</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.mindrecord.html">mindspore.mindrecord</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.nn.html">mindspore.nn</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.nn.probability.html">mindspore.nn.probability</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.nn.transformer.html">mindspore.nn.transformer</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.numpy.html">mindspore.numpy</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.ops.html">mindspore.ops</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.parallel.html">mindspore.parallel</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.parallel.nn.html">mindspore.parallel.nn</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.profiler.html">mindspore.profiler</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.scipy.html">mindspore.scipy</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.train.html">mindspore.train</a></li>
<li class="toctree-l1"><a class="reference internal" href="mindspore.boost.html">mindspore.boost</a></li>
</ul>
<p class="caption"><span class="caption-text">MindSpore C++ API</span></p>
<ul>
<li class="toctree-l1"><a class="reference external" href="https://www.mindspore.cn/lite/api/zh-CN/master/api_cpp/mindspore.html">MindSpore Lite↗</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">MindSpore</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
        
      <li>mindspore.dataset.config</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../_sources/api_python/mindspore.dataset.config.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="mindspore-dataset-config">
<h1>mindspore.dataset.config<a class="headerlink" href="#mindspore-dataset-config" title="Permalink to this headline">¶</a></h1>
<p>config模块能够设置或获取数据处理的全局配置参数。</p>
<p>API示例所需模块的导入代码如下：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">mindspore.dataset</span> <span class="k">as</span> <span class="nn">ds</span>
</pre></div>
</div>
<dl class="function">
<dt id="mindspore.dataset.config.get_auto_num_workers">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">get_auto_num_workers</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.get_auto_num_workers" title="Permalink to this definition">¶</a></dt>
<dd><p>获取当前是否开启自动线程调整。</p>
<p><strong>返回：</strong></p>
<p>bool，表示是否开启自动线程调整。</p>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Get the global configuration of auto number worker feature.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">num_workers</span> <span class="o">=</span> <span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">get_auto_num_workers</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.get_callback_timeout">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">get_callback_timeout</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.get_callback_timeout" title="Permalink to this definition">¶</a></dt>
<dd><p>获取DSWaitedCallback的默认超时时间。
如果出现死锁，等待的函数将在超时时间结束后退出。</p>
<p><strong>返回：</strong></p>
<p>int，表示在出现死锁情况下，用于结束DSWaitedCallback中的等待函数的超时时间（秒）。</p>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Get the global configuration of callback timeout.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># If set_callback_timeout() is never called before, the default value(60) will be returned.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">callback_timeout</span> <span class="o">=</span> <span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">get_callback_timeout</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.get_enable_shared_mem">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">get_enable_shared_mem</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.get_enable_shared_mem" title="Permalink to this definition">¶</a></dt>
<dd><p>获取当前是否开启共享内存。</p>
<p><strong>返回：</strong></p>
<p>bool，表示是否启用共享内存。</p>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Get the flag of shared memory feature.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">shared_mem_flag</span> <span class="o">=</span> <span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">get_enable_shared_mem</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.get_monitor_sampling_interval">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">get_monitor_sampling_interval</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.get_monitor_sampling_interval" title="Permalink to this definition">¶</a></dt>
<dd><p>获取性能监控采样时间间隔的全局配置。</p>
<p><strong>返回：</strong></p>
<p>int，表示性能监控采样间隔时间（毫秒）。</p>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Get the global configuration of monitor sampling interval.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># If set_monitor_sampling_interval() is never called before, the default value(1000) will be returned.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sampling_interval</span> <span class="o">=</span> <span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">get_monitor_sampling_interval</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.get_numa_enable">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">get_numa_enable</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.get_numa_enable" title="Permalink to this definition">¶</a></dt>
<dd><p>获取NUMA的启动状态。
该状态将用于所有进程。</p>
<p><strong>返回：</strong></p>
<p>bool，表示NUMA的启动状态。</p>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Get the global configuration of numa.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">numa_state</span> <span class="o">=</span> <span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">get_numa_enable</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.get_num_parallel_workers">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">get_num_parallel_workers</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.get_num_parallel_workers" title="Permalink to this definition">¶</a></dt>
<dd><p>获取并行工作线程数量的全局配置。
这是并行工作线程数量的值，用于每个操作。</p>
<p><strong>返回：</strong></p>
<p>int，表示每个操作中默认的并行工作进程的数量。</p>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Get the global configuration of parallel workers.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># If set_num_parallel_workers() is never called before, the default value(8) will be returned.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">num_parallel_workers</span> <span class="o">=</span> <span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">get_num_parallel_workers</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.get_prefetch_size">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">get_prefetch_size</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.get_prefetch_size" title="Permalink to this definition">¶</a></dt>
<dd><p>获取数据处理管道的输出缓存队列长度。</p>
<p><strong>返回：</strong></p>
<p>int，表示预取的总行数。</p>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Get the global configuration of prefetch size.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># If set_prefetch_size() is never called before, the default value(16) will be returned.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">prefetch_size</span> <span class="o">=</span> <span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">get_prefetch_size</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.get_seed">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">get_seed</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.get_seed" title="Permalink to this definition">¶</a></dt>
<dd><p>获取随机数的种子。如果随机数的种子已设置，则返回设置的值，否则将返回std::mt19937::default_seed这个默认种子值。</p>
<p><strong>返回：</strong></p>
<p>int，表示种子的随机数量。</p>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Get the global configuration of seed.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># If set_seed() is never called before, the default value(std::mt19937::default_seed) will be returned.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">seed</span> <span class="o">=</span> <span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">get_seed</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.load">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">load</code><span class="sig-paren">(</span><em class="sig-param">file</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.load" title="Permalink to this definition">¶</a></dt>
<dd><p>从文件格式中加载项目配置。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>file</strong> (str) - 表示待加载的配置文件的路径。</p></li>
</ul>
<p><strong>异常：</strong></p>
<ul class="simple">
<li><p><strong>RuntimeError</strong> - 文件无效，解析失败。</p></li>
</ul>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Set new default configuration according to values in the configuration file.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># example config file:</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># {</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1">#     &quot;logFilePath&quot;: &quot;/tmp&quot;,</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1">#     &quot;numParallelWorkers&quot;: 4,</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1">#     &quot;seed&quot;: 5489,</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1">#     &quot;monitorSamplingInterval&quot;: 30</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># }</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">config_file</span> <span class="o">=</span> <span class="s2">&quot;/path/to/config/file&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">config_file</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.set_auto_num_workers">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">set_auto_num_workers</code><span class="sig-paren">(</span><em class="sig-param">enable</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.set_auto_num_workers" title="Permalink to this definition">¶</a></dt>
<dd><p>自动为每个数据集操作设置并行线程数量（默认情况下，此功能关闭）。</p>
<p>如果启用该功能，将自动调整每个数据集操作中的并行线程数量，这可能会覆盖用户传入的并行线程数量或通过ds.config.set_num_parallel_workers()设置的默认值（如果用户未传递任何内容）。</p>
<p>目前，此函数仅针对具有per_batch_map（batch中的运行映射）的YOLOv3数据集进行了优化。
此功能旨在为每个操作的优化线程数量分配提供基线。
并行线程数有所调整的数据集操作将会被记录。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>enable</strong> (bool) - 表示是否启用自动设置线程数量的特性。</p></li>
</ul>
<p><strong>异常：</strong></p>
<ul class="simple">
<li><p><strong>TypeError</strong> - enable不是布尔类型。</p></li>
</ul>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Enable auto_num_worker feature, this might override the num_parallel_workers passed in by user</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">set_auto_num_workers</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.set_callback_timeout">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">set_callback_timeout</code><span class="sig-paren">(</span><em class="sig-param">timeout</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.set_callback_timeout" title="Permalink to this definition">¶</a></dt>
<dd><p>为DSWaitedCallback设置的默认超时时间（秒）。
如果出现死锁，等待函数将在超时时间结束后退出。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>timeout</strong> (int) - 表示在出现死锁情况下，用于结束DSWaitedCallback中等待的超时时间（秒）。</p></li>
</ul>
<p><strong>异常：</strong></p>
<ul class="simple">
<li><p><strong>ValueError</strong> - <cite>timeout</cite> 小于等于0或 <cite>timeout</cite> 大于MAX_INT_32时 <cite>timeout</cite> 无效。</p></li>
</ul>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Set a new global configuration value for the timeout value.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">set_callback_timeout</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.set_enable_shared_mem">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">set_enable_shared_mem</code><span class="sig-paren">(</span><em class="sig-param">enable</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.set_enable_shared_mem" title="Permalink to this definition">¶</a></dt>
<dd><p>设置共享内存标志的是否启用。如果 <cite>shared_mem_enable</cite> 为True，则使用共享内存队列将数据传递给为数据集操作而创建的进程，而这些数据集操作将设置 <cite>python_multiprocessing</cite> 为True。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>enable</strong> (bool) - 表示当 <cite>python_multiprocessing</cite> 为True时，是否在数据集操作中使用共享内存。</p></li>
</ul>
<p><strong>异常：</strong></p>
<ul class="simple">
<li><p><strong>TypeError</strong> - <cite>enable</cite> 不是布尔数据类型。</p></li>
</ul>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Enable shared memory feature to improve the performance of Python multiprocessing.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">set_enable_shared_mem</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.set_monitor_sampling_interval">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">set_monitor_sampling_interval</code><span class="sig-paren">(</span><em class="sig-param">interval</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.set_monitor_sampling_interval" title="Permalink to this definition">¶</a></dt>
<dd><p>设置监测采样的默认间隔时间（毫秒）。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>interval</strong> (int) - 表示用于性能监测采样的间隔时间（毫秒）。</p></li>
</ul>
<p><strong>异常：</strong></p>
<ul class="simple">
<li><p><strong>ValueError</strong> - <cite>interval</cite> 小于等于0或 <cite>interval</cite> 大于MAX_INT_32时， <cite>interval</cite> 无效。</p></li>
</ul>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Set a new global configuration value for the monitor sampling interval.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">set_monitor_sampling_interval</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.set_numa_enable">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">set_numa_enable</code><span class="sig-paren">(</span><em class="sig-param">numa_enable</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.set_numa_enable" title="Permalink to this definition">¶</a></dt>
<dd><p>设置NUMA的默认状态为启动状态。如果 <cite>numa_enable</cite> 为True，则需要确保安装了NUMA库。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>numa_enable</strong> (bool) - 表示是否使用NUMA绑定功能。</p></li>
</ul>
<p><strong>异常：</strong></p>
<ul class="simple">
<li><p><strong>TypeError</strong> - <cite>numa_enable</cite> 不是布尔数据类型。</p></li>
</ul>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Set a new global configuration value for the state of numa enabled.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># Now parallel dataset operators will run with numa bind function</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">set_numa_enable</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.set_num_parallel_workers">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">set_num_parallel_workers</code><span class="sig-paren">(</span><em class="sig-param">num</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.set_num_parallel_workers" title="Permalink to this definition">¶</a></dt>
<dd><p>为并行工作线程数量设置新的全局配置默认值。
此设置会影响所有数据集操作的并行性。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>num</strong> (int) - 表示并行工作线程的数量，用作为每个操作的默认值。</p></li>
</ul>
<p><strong>异常：</strong></p>
<ul class="simple">
<li><p><strong>ValueError</strong> - <cite>num</cite> 小于等于0或 <cite>num</cite> 大于MAX_INT_32时，并行工作线程数量设置无效。</p></li>
</ul>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Set a new global configuration value for the number of parallel workers.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># Now parallel dataset operators will run with 8 workers.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">set_num_parallel_workers</span><span class="p">(</span><span class="mi">8</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.set_prefetch_size">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">set_prefetch_size</code><span class="sig-paren">(</span><em class="sig-param">size</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.set_prefetch_size" title="Permalink to this definition">¶</a></dt>
<dd><p>设置管道中线程的队列容量。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>size</strong> (int) - 表示缓存队列的长度。</p></li>
</ul>
<p><strong>异常：</strong></p>
<ul class="simple">
<li><p><strong>ValueError</strong> - 当 <cite>size</cite> 小于等于0或 <cite>size</cite> 大于 <cite>MAX_INT_32</cite> 时，线程的队列容量无效。</p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>用于预取的总内存可能会随着工作线程数量的增加而快速增长，所以当工作线程数量大于4时，每个工作线程的预取大小将减少。
每个工作线程在运行时预取大小将是 <cite>prefetchsize</cite> * (4 / <cite>num_parallel_workers</cite> )。</p>
</div>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Set a new global configuration value for the prefetch size.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">set_prefetch_size</span><span class="p">(</span><span class="mi">1000</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.set_seed">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">set_seed</code><span class="sig-paren">(</span><em class="sig-param">seed</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.set_seed" title="Permalink to this definition">¶</a></dt>
<dd><p>如果设置了种子，生成的随机数将被固定，这有助于产生确定性结果。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>此函数在Python随机库和numpy.random库中设置种子，以便随机进行确定性Python增强。此函数应与创建的每个迭代器一起调用，以重置随机种子。在管道中，这并不保证 <cite>num_parallel_workers</cite> 大于1。</p>
</div>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>seed</strong> (int) - 表示随机数量的种子。该参数用于生成确定性随机数。</p></li>
</ul>
<p><strong>异常：</strong></p>
<ul class="simple">
<li><p><strong>ValueError</strong> - <cite>seed</cite> 小于0或 <cite>seed</cite> 大于MAX_UINT_32时， <cite>seed</cite> 无效。</p></li>
</ul>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Set a new global configuration value for the seed value.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># Operations with randomness will use the seed value to generate random values.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">set_seed</span><span class="p">(</span><span class="mi">1000</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.set_sending_batches">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">set_sending_batches</code><span class="sig-paren">(</span><em class="sig-param">batch_num</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.set_sending_batches" title="Permalink to this definition">¶</a></dt>
<dd><p>在昇腾设备中使用sink_mode=True进行训练时，设置默认的发送批次。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>batch_num</strong> (int) - 表示总的发送批次。当设置了 <cite>batch_num</cite> 时，它将会等待，除非增加发送批次。默认值为0，表示将发送数据集中的所有批次。</p></li>
</ul>
<p><strong>异常：</strong></p>
<ul class="simple">
<li><p><strong>TypeError</strong> - <cite>batch_num</cite> 不是int类型。</p></li>
</ul>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Set a new global configuration value for the sending batches</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">set_sending_batches</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.set_enable_autotune">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">set_enable_autotune</code><span class="sig-paren">(</span><em class="sig-param">enable</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.set_enable_autotune" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the default state of AutoTune flag. If it is True, will facilitate users to improve
performance for a given workload by automatically finding the better settings for data pipeline.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>enable</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a>) – Whether to use AutoTune feature when running data pipeline.</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/library/exceptions.html#TypeError" title="(in Python v3.8)"><strong>TypeError</strong></a> – If enable is not a boolean data type.</p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Enable AutoTune</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">set_enable_autotune</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.get_enable_autotune">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">get_enable_autotune</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.get_enable_autotune" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the default state of AutoTune enabled variable.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>bool, the state of AutoTune enabled variable (default=True).</p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Get the flag of AutoTune feature.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">autotune_flag</span> <span class="o">=</span> <span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">get_enable_autotune</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.set_autotune_interval">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">set_autotune_interval</code><span class="sig-paren">(</span><em class="sig-param">interval</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.set_autotune_interval" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the interval (in steps) for data pipeline autotuning. Setting interval to 0
configures autotune to run after every epoch instead of after a certain number of steps.
Default value is set to 0, meaning epoch based autotuning.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>interval</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Interval (in steps) to serve as gap for consecutive AutoTune runs.</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/library/exceptions.html#ValueError" title="(in Python v3.8)"><strong>ValueError</strong></a> – If interval is invalid when interval &lt; 0 or interval &gt; MAX_INT_32.</p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Set a new global configuration value for the autotuning interval.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">set_autotune_interval</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="mindspore.dataset.config.get_autotune_interval">
<code class="sig-prename descclassname">mindspore.dataset.config.</code><code class="sig-name descname">get_autotune_interval</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.dataset.config.get_autotune_interval" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the global configuration of pipeline autotuning step interval.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>int, interval (in steps) for data pipeline autotuning.</p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="c1"># Get the global configuration of the autotuning interval.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># If set_autotune_interval() is never called before, the default value(30) will be returned.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">autotune_interval</span> <span class="o">=</span> <span class="n">ds</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">get_autotune_interval</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

</div>


           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="mindspore.dataset.text.html" class="btn btn-neutral float-right" title="mindspore.dataset.text" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="dataset_audio/mindspore.dataset.audio.utils.ScaleType.html" class="btn btn-neutral float-left" title="mindspore.dataset.audio.utils.ScaleType" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2021, MindSpore.

    </p>
  </div>
    
    
    
    Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>